#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    string addStrings(string num1, string num2) {
        string nums3;
        int num1End = (num1.size()) - 1;
        int num2End = (num2.size()) - 1;
        int with = 0;
        int extra = 0;
        //cout << num1End << num2End << endl;
        while (num1End >= 0 && num2End >= 0)
        {
            with = (num1[num1End--] + num2[num2End--] - 48 * 2) + extra;
            nums3 += (with % 10) + 48;
            extra = with / 10;
        }
        while (num1End >= 0 || num2End >= 0)
        {
            if (num1End >= 0)
            {
                with = num1[num1End--] - 48 + extra;
                nums3 += (with % 10) + 48;
                extra = with / 10;
            }
            if (num2End >= 0)
            {
                with = num2[num2End--] - 48 + extra;
                nums3 += (with % 10) + 48;
                extra = with / 10;
            }
        }
        if (extra)
        {
            nums3 += extra + 48;
        }
        reverse(nums3.begin(), nums3.end());

        return nums3;
    }
};